<?php
require_once("include/auth.php");
require_once("include/db.php");
header("Content-Type: application/json");

$result = query_device($_SESSION['user_id']);
if (!$result) {
    $data['check'] = 'Not Found';
    echo json_encode($data);
    exit();
}

while ($row = mysql_fetch_assoc($result)) {
    $array_token[] = $row['Token'];
    $array_name[] = $row['Device_Name'];
}

$data = array(
    'check' => 'Success',
    'array_token' => $array_token,
    'array_name' => $array_name,
);

echo json_encode($data);
